{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "03600fe7",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "import qiskit.tools.jupyter\n",
    "%qiskit_version_table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8ea40ac6",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "from qiskit import IBMQ, QuantumCircuit, transpile\n",
    "from qiskit.tools import job_monitor\n",
    "from qiskit.visualization import plot_histogram, plot_gate_map"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aaf67d5c",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "# Saving your IBM Quantum account in ~/.qiskit dir\n",
    "# May remove after first execution\n",
    "IBMQ.save_account('<API TOKEN HERE>')\n",
    "# Loading your IBM Quantum account(s)\n",
    "IBMQ.load_account()\n",
    "provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')\n",
    "backend = provider.get_backend('ibmq_lima')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9b885b33",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "qc = QuantumCircuit(2)\n",
    "qc.h(0)\n",
    "qc.cx(0, 1)\n",
    "qc.measure_all()\n",
    "qc.draw(output='mpl')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bcf0dbda",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "import qiskit.tools.jupyter\n",
    "%qiskit_job_watcher "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fefab72",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [],
   "source": [
    "# run job on real hardware\n",
    "job = backend.run(transpile(qc, backend=backend), shots=1024)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "547979ae",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [],
   "source": [
    "# or retrieve previously-run job\n",
    "job = backend.retrieve_job('6101be0fab2460c9c6a3e42e') # your job id here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d86a0aa0",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "plt.style.use('dark_background')\n",
    "plot_histogram(job.result().get_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c925f8de",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "celltoolbar": "Slideshow",
  "kernelspec": {
   "display_name": "qiskit (stable)",
   "language": "python",
   "name": "qiskit-stable"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
